<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateTableKmsUserLoginHistory extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('kms_user_login_history', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("userId")->default(0)->comment("rmsUserID");
            $table->string("userAgent", 300)->default("")->comment("user-agent");
            $table->string("ip", 24)->default("")->comment("ip地址");
            $table->string("appVersion", 24)->default("")->comment("当前应用版本");


            $table->string("longitude", 36)->default("")->comment("经度");
            $table->string("latitude", 36)->default("")->comment("纬度");

            $table->string("deviceModel", 64)->default("")->comment("登录设备型号");
            $table->string("deviceSystem", 64)->default("")->comment("登录设备系统");
            $table->string("deviceSerialNumber", 120)->default("")->comment("登录设备序列号");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('删除');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = 'kms - 用户登录历史记录';
            $table->index("userId", "idx_userId");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('kms_user_login_history');
    }
}
